package com.site.wisdom_construction.controller.scheduleModule;

import com.site.wisdom_construction.responseEntity.JsonResult;
import com.site.wisdom_construction.responseEntity.OneDataResult;
import com.site.wisdom_construction.responseEntity.Page;
import com.site.wisdom_construction.service.scheduleModule.AerialProgressService;
import com.site.wisdom_construction.service.scheduleModule.FloorProgressService;
import com.site.wisdom_construction.util.verification.NoToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author daiyifei
 * @Date 2022/1/12
 * @Description
 */
@Api(tags = "楼层进度接口")
@RestController
@RequestMapping("FloorProgress")
@CrossOrigin
public class FloorProgressController {
    @Autowired
    private FloorProgressService floorProgressService;

    @ApiOperation(value = "增加楼层进度信息", notes = "测试数据:")
    @PostMapping("/insertFloorProgress")
    public JsonResult insertFloorProgress(@RequestBody Map map){
        JsonResult jsonResult = new JsonResult();
        int i = floorProgressService.insertFloorProgress(map);
        if (i==1){
            jsonResult.setCode(200);
            jsonResult.setMessage("成功!");
        }else {
            jsonResult.setCode(20006);
            jsonResult.setMessage("修改!");
        }
        return jsonResult;
    }

    @ApiOperation(value = "修改楼层进度", notes = "测试数据:")
    @PostMapping("/updateFloorProgressByMap")
    public JsonResult updateFloorProgressByMap(@RequestBody Map map){
        JsonResult jsonResult = new JsonResult();
        int i = floorProgressService.updateFloorProgressByMap(map);
        if (i==1){
            jsonResult.setCode(200);
            jsonResult.setMessage("成功修改!");
        }else {
            jsonResult.setCode(20006);
            jsonResult.setMessage("修改失败!");
        }
        return jsonResult;
    }

    @ApiOperation(value = "修改仙居九局楼层进度", notes = "测试数据:")
    @PostMapping("/updateFloorProgress")
    public JsonResult updateFloorProgress(@RequestBody Map map){
        JsonResult jsonResult = new JsonResult();
        int i = floorProgressService.updateFloorProgress(map);
        if (i==1){
            jsonResult.setCode(200);
            jsonResult.setMessage("成功修改!");
        }else {
            jsonResult.setCode(20006);
            jsonResult.setMessage("修改失败!");
        }
        return jsonResult;
    }

    @ApiOperation(value = "查询全部楼层进度", notes = "测试数据:")
    @RequestMapping("/findFloorProgress")
    @NoToken
    public OneDataResult findFloorProgress(@RequestBody Map map) {
        OneDataResult oneDataResult = new OneDataResult();
        oneDataResult.setData(floorProgressService.findFloorProgress(map));
        return oneDataResult;
    }
}
